package com.hong.strategy.register;

import com.hong.Config.ConfigManager;
import com.hong.Config.RegisterConfig;
import com.hong.RpcServer;
import com.hong.qrpc.utils.StringUtils;
import com.hong.strategy.PropertiesStrategy;

import java.util.Map;

/**
 * @Author HQT
 * @Date 2022/8/2 11:31
 */
public class StartBySpringStrategy implements PropertiesStrategy {
    @Override
    public void disposeProperties(RpcServer rpcServer) {
        ConfigManager configManager = rpcServer.getConfigManager();
        Map<Object, Object> profile = configManager.getProfile();
        String startByString = (String) profile.get("start.by.string");
        if (!StringUtils.isEmpty(startByString)) {
            RegisterConfig registerConfig = rpcServer.getConfigManager().getRegisterConfig();
            registerConfig.setStartBySpring(Boolean.parseBoolean(startByString));
        }
    }
}
